<template>
	<view id="msgDel">
		<view class="msg">			
			<view class="title">
				{{title}}
			</view>
			<view class="time">
				{{sendTime}}
			</view>
			<view class="content">
				{{message}}
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id:"",
				title:"",
				message:"",
				sendTime:''
			};
		},
		onShow(){
			this.getMsgDel()
			this.lookMsg()
		},
		onLoad(option){
		    let id = decodeURIComponent(option.id);
			this.id=id
		  },
		methods:{
			 parseTime(time, cFormat) {
			      if (arguments.length === 0) {
			        return null;
			      }
			      const format = cFormat || "{y}-{m}-{d} {h}:{i}:{s}";
			      let date;
			      if (typeof time === "object") {
			        date = time;
			      } else {
			        if (("" + time).length === 10) time = parseInt(time) * 1000;
			        date = new Date(time);
			      }
			      const formatObj = {
			        y: date.getFullYear(),
			        m: date.getMonth() + 1,
			        d: date.getDate(),
			        h: date.getHours(),
			        i: date.getMinutes(),
			        s: date.getSeconds(),
			        a: date.getDay()
			      };
			      const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
			        let value = formatObj[key];
			        if (key === "a")
			          return ["一", "二", "三", "四", "五", "六", "日"][value - 1];
			        if (result.length > 0 && value < 10) {
			          value = "0" + value;
			        }
			        return value || 0;
			      });
			      return time_str;
			    },
			getMsgDel() {
				let that = this;
					this.$store
					    .dispatch("UpdStatus",{id:this.id})
					    .then((response) => {
							
					    })
					    .catch(() => {});
			},
			lookMsg(){
				let that = this;
				this.$store
				    .dispatch("LookMsg",{id:this.id})
				    .then((response) => {
					if(response.data.code==0){
						this.title=response.data.obj.title
						this.message=response.data.obj.message
						this.sendTime=this.parseTime(response.data.obj.sendTime)
					}
				    })
				    .catch(() => {});
			}
		}
	}
</script>

<style lang="less">
	#msgDel{
		.msg{
			width: 90%;
			margin: 0 auto;
			padding-top: 60rpx;
		}
		.title{
			font-size:30rpx;
			color: #222222;
			font-weight: bold;
			margin: 20rpx 0;
			position: relative;
			text-align: center;
		}
		.time{
			font-size: 26rpx;
			color: #888888;
			text-align: center;
		}
		.content{
			font-size: 28rpx;
			color: #222222;
			line-height: 48rpx;
			margin-top: 48rpx;
		}
	}
</style>
